package pers.zb.center.web.boss.socket.notice.permission.update.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import pers.zb.center.web.boss.socket.notice.permission.update.handler.PermissionUpdateNoticeWebSocketHandler;
import pers.zb.center.web.boss.socket.notice.permission.update.interceptor.PermissionUpdateNoticeInterceptor;


@Configuration
@EnableWebMvc
@EnableWebSocket
public class PermissionUpdateNoticeWebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {

    public PermissionUpdateNoticeWebSocketConfig() {
    }

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(PermissionUpdateNoticeWebSocketHandler(), "/websck_notice_permission_update").addInterceptors(new PermissionUpdateNoticeInterceptor());
        registry.addHandler(PermissionUpdateNoticeWebSocketHandler(), "/sockjs/websck_notice_permission_update").addInterceptors(new PermissionUpdateNoticeInterceptor()).withSockJS();

    }

    @Bean
    public WebSocketHandler PermissionUpdateNoticeWebSocketHandler() {
        return new PermissionUpdateNoticeWebSocketHandler();
    }

}
